﻿using BZOrderPrint.DAL.Entity;
using Stimulsoft.Report;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BZOrderPrint.PDF
{
    public static class LabelHelper
    {

        public static void PrintShopLabel(BzOrderEntity order)
        {
            try
            {

                string path = System.AppDomain.CurrentDomain.BaseDirectory + @"File\shop.mrt";
                string name = !string.IsNullOrEmpty(order.MemberName) ? order.MemberName : order.Phone;
                List<object> printOrderinfo = new List<object> {
                 new {

                    Sender = order.OrderShopName,                    //卖家
                    FromAddress = order.OrderShopName,              //卖家电话                                     
                    ToPersonName = name,          //买家名字
                    ToPhoneNumber = order.Phone,         //买家电话
                    TraceID = order.OrderCode,                //跟踪号 
                    OrderID = order.OrderCode
                  }
                 };

                StiReport report = new StiReport();
                report.Load(path);
                report.RegBusinessObject("GLSModel", printOrderinfo);
                report.PrinterSettings.ShowDialog = false;

                report.Render(false);
                report.Print(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void PrintTeamLabel(BzOrderEntity order)
        {
            try
            {

                string path = System.AppDomain.CurrentDomain.BaseDirectory + @"File\team.mrt";
                string name = !string.IsNullOrEmpty(order.MemberName) ? order.MemberName : order.Phone;
                List<object> printOrderinfo = new List<object> {
                 new {

                    Sender = order.OrderShopName,                    //卖家
                    FromAddress = order.OrderShopName,              //卖家电话  
                    ToAddressLine=order.Address,
                    ToPersonName = name,          //买家名字
                    ToPhoneNumber = order.Phone,         //买家电话
                  }
                 };

                StiReport report = new StiReport();
                report.Load(path);
                report.RegBusinessObject("GLSModel", printOrderinfo);
                report.PrinterSettings.ShowDialog = false;

                report.Render(false);
                report.Print(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}




